package io.github.uicdb.et.data;

import io.github.uicdb.et.*;
import io.github.uicdb.et.data.recipe.ElementRecipeBuilder;
import io.github.uicdb.et.data.recipe.ExtractRecipeBuilder;
import io.github.uicdb.et.data.recipe.TurnInRecipeBuilder;
import io.github.uicdb.et.item_data.ItemElementData;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.RecipeOutput;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.neoforged.neoforge.common.Tags;
import net.neoforged.neoforge.common.crafting.DataComponentIngredient;

import java.util.concurrent.CompletableFuture;

public class ETRepiceProvider extends RecipeProvider {
    public ETRepiceProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
        super(output, registries);
    }

    @Override
    protected void buildRecipes(RecipeOutput recipeOutput) {
        ExtractRecipeBuilder.of(ItemTags.LOGS, ModElements.WOOD.holder(), 25)
                .with(ModElements.YANG.holder(), 10)
                .with(ModElements.METAL.holder(), 20)
                .with(ModElements.WATER.holder(), 30)
                .with(ModElements.FIRE.holder(), 40)
                .with(ModElements.YANG.holder(), 50)
                .save(recipeOutput, ResourceLocation.fromNamespaceAndPath(ElementalTheory.MODID, "extract/log"));
        ElementRecipeBuilder.ofResult(ModItems.DOGE_HAPPY.asItem())
                .input(Tags.Items.FOODS_RAW_MEAT)
                .input(ModElements.METAL, 2)
                .input(ModElements.WATER, 10)
                .input(ModElements.FIRE, 8)
                .save(recipeOutput, ResourceLocation.fromNamespaceAndPath(ElementalTheory.MODID, "element/doge_happy"));
        TurnInRecipeBuilder.of(ModElements.EARTH, 10, ModTags.ELEMENT_WEAPON, 25)
                .save(recipeOutput, ResourceLocation.fromNamespaceAndPath(ElementalTheory.MODID, "turn_in/weapon_earth"));
        TurnInRecipeBuilder.ofItem(
                        ModElements.YANG.holder(),
                        10,
                        DataComponentIngredient.of(false,
                                ModItemDataComponents.ITEM_ELEMENT_DATA,
                                new ItemElementData(ModElements.WOOD, 10, 10),
                                Items.WOODEN_SWORD
                        ),
                        new ItemStack(ModItems.LIGHTNING_SWORD.asItem()))
                .recipeTime(5)
                .save(recipeOutput, ResourceLocation.fromNamespaceAndPath(ElementalTheory.MODID, "turn_in/charge_you_sword"));
        TurnInRecipeBuilder.ofItem(
                        ModElements.YANG.holder(),
                        2,
                        Ingredient.of(Items.TORCH),
                        new ItemStack(ModItems.SUNDEE.asItem()))
                .recipeTime(5)
                .save(recipeOutput, ResourceLocation.fromNamespaceAndPath(ElementalTheory.MODID, "turn_in/torch2sundee"));
        TurnInRecipeBuilder.ofItem(
                        ModElements.WATER.holder(),
                        40,
                        Ingredient.EMPTY,
                        new ItemStack(ModItems.WATER_WATER.asItem())
                ).recipeTime(10)
                .save(recipeOutput, ResourceLocation.fromNamespaceAndPath(ElementalTheory.MODID, "turn_in/water_water"));

    }
}
